<?php

use think\migration\Migrator;

class CreateNodesFrpsTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $this->table('nodes_frps', ['comment' => '节点frps表', 'id' => 'id', 'primary_key' => ['id']])
            ->addColumn('nid', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '节点id'])
            ->addColumn('bind_port', 'string', ['limit' => 10, 'default' => '', 'comment' => '服务端口'])
            ->addColumn('vhost_http_port', 'string', ['limit' => 10, 'default' => '', 'comment' => '客户端端口'])
            ->addColumn('vhost_https_port', 'string', ['limit' => 10, 'default' => '', 'comment' => '客户端https端口'])
            ->addColumn('token', 'string', ['limit' => 32,'default'=> md5(env('JWT_STRKEY')),'comment' => '令牌'])
            ->addColumn('subdomain_host', 'string', ['limit' => 250, 'default' => '', 'comment' => '自定义域名'])
            ->addColumn('privilege_allow_ports', 'string', ['limit' => 250, 'default' => '', 'comment' => '开放端口'])
            ->addColumn('max_pool_count', 'integer', ['limit' => 10, 'default' => 5, 'comment' => '最大连接数'])
            ->addColumn('dashboard_port', 'integer', ['limit' => 10, 'default' => 17500, 'comment' => '这个是frp内网穿透服务器的web界面的端口和账号密码'])
            ->addColumn('dashboard_user', 'string', ['limit' => 10, 'default' => 'admin', 'comment' => 'web界面的账号'])
            ->addColumn('dashboard_pwd', 'string', ['limit' => 32, 'default' => md5(md5(env('JWT_STRKEY'))), 'comment' => 'web界面的密码'])
            ->addColumn('state', 'biginteger', ['limit' => 10,'default' => 0, 'comment' => '状态 1正常 0异常'])
            ->addColumn('state_remark', 'string', ['limit' => 250, 'default' => '', 'comment' => '状态备注'])
            ->addColumn('expire_time', 'datetime', ['null' => true,'comment' => '到期时间'])
            ->addTimestamps()
            ->addIndex('nid')
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable('nodes_frps');
    }
}
